home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2000 June (IDG) / Macworld_June_2000.iso / Shareware World / Utilities / Printing / MacGhostView / ps2pdf script < prev    next >
Encoding:
Text File  |  2000-03-30  |  1.6 KB  |  45 lines  |  [TEXT/ToyS]

  1. -- Save this script as an application and then drop a postscript file on it.
  2. -- Use -dCompatibilityLevel=1.2 to convert PostScript to PDF 1.2 (Acrobat 3-and-later compatible).
  3. -- Use -dCompatibilityLevel=1.3 to convert PostScript to PDF 1.2 (Acrobat 4-and-later compatible).
  4.  
  5.  
  6.  
  7. on open (theList)
  8.     repeat with afile in theList
  9.         convert(afile)
  10.     end repeat
  11.     quit
  12. end open
  13.  
  14. on convert(afile)
  15.     set old_delimits to AppleScript's text item delimiters
  16.     set AppleScript's text item delimiters to ":"
  17.     -- pull the path out as a string and strip off the filename
  18.     set path_text to (afile as text)
  19.     set path_list to (text items of path_text)
  20.     set final_path to items 1 thru ((count of path_list) - 1) of path_list
  21.     set infile to last item of path_list
  22.     set working_directory to (final_path as string) & ":"
  23.     set AppleScript's text item delimiters to "."
  24.     set file_text to (text items of infile)
  25.     set basename to item 1 of file_text
  26.     set AppleScript's text item delimiters to old_delimits
  27.     if infile = "" then
  28.         display dialog "No Postscript file selected." buttons {"OK"} default button 1
  29.         return
  30.     end if
  31.     set outfile to basename & ".pdf"
  32.     set command to "gs -dCompatibilityLevel=1.2 -dMaxSubsetPct=100 -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=" & outfile & space  & "-c save pop -f" & space & infile
  33.     with timeout of 300 seconds
  34.         tell application "ps2pdf"
  35.             activate
  36.             set status to (exec command in the folder alias working_directory)
  37.             if status = 0 then
  38.                 tell application "Finder"
  39.                     set creator type of file (working_directory & outfile) to "CARO"
  40.                     set file type of file (working_directory & outfile) to "PDF "
  41.                 end tell
  42.             end if
  43.         end tell
  44.     end timeout
  45. end convert